From e168d17283adfc75b32a18b85c99b053a9c350ab Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Sat, 29 Jan 2022 08:27:03 -0700 Subject: [PATCH] Wintec tes format (#835) * convert wintec_tes for Format class. * add new h file. * add default init. --- CMakeLists.txt | 1 + GPSBabel.pro | 1 + vecs.h | 4 +-- wintec_tes.cc | 51 +++++++++---------------------- wintec_tes.h | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 101 insertions(+), 38 deletions(-) create mode 100644 wintec_tes.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 97b91874b..fe1e5bcf3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -259,6 +259,7 @@ set(HEADERS unicsv.h units.h vecs.h + wintec_tes.h xcsv.h xmlgeneric.h jeeps/garminusb.h diff --git a/GPSBabel.pro b/GPSBabel.pro index bdb346a6f..01ac58966 100644 --- a/GPSBabel.pro +++ b/GPSBabel.pro @@ -246,6 +246,7 @@ HEADERS = \ unicsv.h \ units.h \ vecs.h \ + wintec_tes.h \ xcsv.h \ xmlgeneric.h \ jeeps/garminusb.h \ diff --git a/vecs.h b/vecs.h index 4a06a8a70..c5f0d7a2b 100644 --- a/vecs.h +++ b/vecs.h @@ -48,6 +48,7 @@ #include "skytraq.h" #include "subrip.h" #include "unicsv.h" +#include "wintec_tes.h" #include "xcsv.h" extern ff_vecs_t geo_vecs; @@ -122,7 +123,6 @@ extern ff_vecs_t mmo_vecs; extern ff_vecs_t v900_vecs; extern ff_vecs_t enigma_vecs; extern ff_vecs_t teletype_vecs; -extern ff_vecs_t wintec_tes_vecs; extern ff_vecs_t format_garmin_xt_vecs; extern ff_vecs_t mapbar_track_vecs; extern ff_vecs_t f90g_track_vecs; @@ -315,7 +315,7 @@ private: LegacyFormat teletype_fmt {teletype_vecs}; SkytraqfileFormat skytraq_ffmt; MinihomerFormat miniHomer_fmt; - LegacyFormat wintec_tes_fmt {wintec_tes_vecs}; + WintecTesFormat wintec_tes_fmt; SubripFormat subrip_fmt; LegacyFormat format_garmin_xt_fmt {format_garmin_xt_vecs}; GarminFitFormat format_fit_fmt; diff --git a/wintec_tes.cc b/wintec_tes.cc index bef8fca28..f9de12d9f 100644 --- a/wintec_tes.cc +++ b/wintec_tes.cc @@ -20,26 +20,30 @@ */ -#include "defs.h" +#include "wintec_tes.h" -#define MYNAME "wintec_tes" +#include // for time_t, tm +#include // for memset + +#include "defs.h" // for Waypoint, mkgmtime, track_add_head, track_add_wpt, waypt_add, route_head -static gbfile* fin; -static void -wintec_tes_rd_init(const QString& fname) +#define MYNAME "wintec_tes" + +void +WintecTesFormat::rd_init(const QString& fname) { fin = gbfopen(fname, "r", MYNAME); } -static void -wintec_tes_rd_deinit() +void +WintecTesFormat::rd_deinit() { gbfclose(fin); } -static time_t -wintec_date_to_time(uint32_t w) +time_t +WintecTesFormat::wintec_date_to_time(uint32_t w) { struct tm tm; memset(&tm, 0, sizeof(tm)); @@ -53,8 +57,8 @@ wintec_date_to_time(uint32_t w) return mkgmtime(&tm); } -static void -wintec_tes_read() +void +WintecTesFormat::read() { auto* trk = new route_head; track_add_head(trk); @@ -91,28 +95,3 @@ wintec_tes_read() track_add_wpt(trk, wpt); } } - -static -QVector wintec_tes_args = { -}; - -ff_vecs_t wintec_tes_vecs = { - ff_type_file, - { - ff_cap_read /* waypoints */, - ff_cap_read /* tracks */, - ff_cap_none /* routes */ - }, - wintec_tes_rd_init, - nullptr, - wintec_tes_rd_deinit, - nullptr, - wintec_tes_read, - nullptr, - nullptr, - &wintec_tes_args, - CET_CHARSET_ASCII, 0 /* ascii is the expected character set */ - /* not fixed, can be changed through command line parameter */ - , NULL_POS_OPS, - nullptr -}; diff --git a/wintec_tes.h b/wintec_tes.h new file mode 100644 index 000000000..6daf96011 --- /dev/null +++ b/wintec_tes.h @@ -0,0 +1,82 @@ +/* + + Wintec tes support. + + Copyright (C) 2010 Robert Lipe, robertlipe+source@gpsbabel.org + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + */ +#ifndef WINTEC_TES_H_INCLUDED_ +#define WINTEC_TES_H_INCLUDED_ + +#include // for QString +#include // for QVector + +#include // for uint32_t +#include // for time_t + +#include "defs.h" // for ff_cap, arglist_t, ff_cap_read, CET_CHARSET_ASCII, ff_cap_none, ff_type, ff_type_file +#include "format.h" // for Format +#include "gbfile.h" // for gbfile + + +class WintecTesFormat : public Format +{ +public: + QVector* get_args() override + { + return &wintec_tes_args; + } + + ff_type get_type() const override + { + return ff_type_file; + } + + QVector get_cap() const override + { + /* waypoints, tracks, routes */ + return { ff_cap_read, ff_cap_read, ff_cap_none }; + } + + QString get_encode() const override + { + return CET_CHARSET_ASCII; + } + + int get_fixed_encode() const override + { + return 0; + } + + void rd_init(const QString& fname) override; + void read() override; + void rd_deinit() override; + +private: + /* Member Functions */ + + static time_t wintec_date_to_time(uint32_t w); + + /* Data Members */ + + gbfile* fin{}; + + QVector wintec_tes_args = { + }; + +}; +#endif // WINTEC_TES_H_INCLUDED_ -- 2.30.2